# Author: HZT
# Date: 2023/9/1
import time
import page
from base.base import Base
import pyautogui


class WebCkPm(Base):
    # 点击人员管理
    def ck_pm_click_rygl(self):
        self.base_find_first(page.web_ck_pm_rygl).click()

    # 点击新增
    def ck_pm_click_xz(self):
        self.base_click(page.web_ck_pm_xz)

    # 点击快速创建
    def ck_pm_click_kscj(self):
        self.base_click(page.web_ck_pm_kscj)

    # 点击快速提交
    def ck_pm_click_kstj(self):
        self.base_click(page.web_ck_pm_kstj)

    # 点击编辑
    def ck_pm_click_bj(self):
        self.base_click(page.web_ck_pm_bj)

    # 获取新增元素
    def ck_pm_get_xz(self):
        return self.base_find(page.web_ck_pm_xz)

    # 点击显示
    def ck_pm_click_xs(self):
        self.base_click(page.web_ck_pm_xs)

    # 点击删除
    def ck_pm_click_sc(self):
        self.base_click(page.web_ck_pm_sc)

    # 输入用户名
    def ck_pm_input_username(self, username):
        self.base_input(page.web_ck_pm_username, username)

    # 输入名称
    def ck_pm_input_name(self, name):
        self.base_input(page.web_ck_pm_name, name)

    # 输入密码
    def ck_pm_input_pwd(self, pwd):
        self.base_input(page.web_ck_pm_pwd, pwd)

    # 点击状态
    def ck_pm_click_zt(self):
        self.base_click(page.web_ck_pm_zt)

    # 点击新增提交
    def ck_pm_click_xztj(self):
        self.base_click(page.web_ck_pm_xztj)

    # 点击编辑提交
    def ck_pm_click_bjtj(self):
        self.base_click(page.web_ck_pm_bjtj)

    # 输入用户名_快速
    def ck_pm_input_usernameks(self, usernameks):
        self.base_input(page.web_ck_pm_usernameks, usernameks)

    # 输入名称_快速
    def ck_pm_input_nameks(self, nameks):
        self.base_input(page.web_ck_pm_nameks, nameks)

    # 输入密码_快速
    def ck_pm_input_pwdks(self, pwdks):
        self.base_input(page.web_ck_pm_pwdks, pwdks)

    # 获取成功弹窗
    def ck_pm_get_cg(self):
        return self.base_get_text(page.web_ck_pm_cgtc)

    # 获取页面总记录条数
    def ck_pm_get_total(self):
        return self.base_get_text(page.web_ck_pm_total)

    # 获取用户名提示
    def ck_pm_get_usernamets(self):
        return self.base_get_text(page.web_ck_pm_usernamets)

    # 获取名称提示
    def ck_pm_get_namets(self):
        return self.base_get_text(page.web_ck_pm_namets)

    # 获取密码提示
    def ck_pm_get_pwdts(self):
        return self.base_get_text(page.web_ck_pm_pwdts)

    # 点击操作按钮
    def ck_pm_click_cz(self):
        self.base_click(page.web_ck_pm_cz)

    # 点击删除提交
    def ck_pm_click_sctj(self):
        self.base_click(page.web_ck_pm_sctj)

    # 点击删除ok
    def ck_pm_click_scok(self):
        self.base_click(page.web_ck_pm_scok)

    # 获取删除成功文本
    def ck_pm_get_sccg(self):
        return self.base_get_text(page.web_ck_pm_sccg)

    # 点击角色
    def ck_pm_click_js(self):
        self.base_click(page.web_ck_pm_js)

    # 点击卡商公司-员工
    def ck_pm_click_ksgsyg(self):
        self.base_click(page.web_ck_pm_yg)

    # 获取分组列表
    def ck_pm_get_fzlb(self):
        return self.base_get_text(page.web_ck_pm_fzlb)

    # 组合快速创建功能
    def ck_pm_kscj(self, usernameks, nameks, pwdks):
        self.ck_pm_click_kscj()
        time.sleep(1)
        self.ck_pm_input_usernameks(usernameks)
        time.sleep(1)
        self.ck_pm_input_nameks(nameks)
        time.sleep(1)
        self.ck_pm_input_pwdks(pwdks)
        time.sleep(1)
        # 选择角色
        self.ck_pm_click_js()
        time.sleep(1)
        self.ck_pm_click_ksgsyg()
        time.sleep(1)
        self.ck_pm_click_kstj()
        time.sleep(1)

    # 组合新增用户功能
    def ck_pm_xz(self, username, name, pwd, fz=None):
        self.ck_pm_click_xz()
        time.sleep(1)
        self.ck_pm_input_username(username)
        time.sleep(1)
        self.ck_pm_input_name(name)
        time.sleep(1)
        self.ck_pm_input_pwd(pwd)
        time.sleep(1)
        # 选择角色
        self.ck_pm_click_js()
        time.sleep(1)
        self.ck_pm_click_ksgsyg()
        if fz:
            self.base_input(page.web_ck_pm_fz, fz)
            pyautogui.press('enter')
        time.sleep(1)
        self.ck_pm_click_xztj()

    # 组合编辑用户功能
    def ck_pm_bj(self, username, name, pwd):
        self.ck_pm_click_cz()
        time.sleep(1)
        self.ck_pm_click_bj()
        time.sleep(1)
        self.ck_pm_input_username(username)
        time.sleep(1)
        self.ck_pm_input_name(name)
        time.sleep(1)
        self.ck_pm_input_pwd(pwd)
        time.sleep(1)
        self.ck_pm_click_bjtj()
        time.sleep(1)
